<?php
	$fieldOptions = $pageInfo['DynamicPage']['fieldOptions'];
	if($showActive != 1 && cr("DynamicPage.field") ==$pageInfo['DynamicPage']['field'])
	{
		if(isset($fieldOptions[cr("DynamicPage.value")]))
		{
			unset($fieldOptions[cr("DynamicPage.value")]);
		}
	}
	if($order)
	{
		natcasesort($fieldOptions);
		if(low($order) == "desc")
		{
				$fieldOptions = array_reverse($fieldOptions,true);		
		}else
		{
			//natcasesort($fieldOptions);			
		}
	}
	if(count($visibleLinksKeys) > 0)
	{
		
		$valuesToShow = $visibleLinksKeys;
	}else
	{
		if(!$limit)
		{
			$limit = 5;
		}
		$chunks = array_chunk(array_keys($fieldOptions),$limit);
		$valuesToShow = $chunks[0];
	}
	
?>
<?php 
	//show visible fields
	$hiddenDivId = $pageInfo['DynamicPage']['field']."_hidden_links";
?>
<div class="inder_text_more">
    <h2 class="h2_txt_title">Browse listings by location:</h2>
    <div class="visible_links">
	<ul>
		<?php foreach($valuesToShow as $valueToShow){?>
				<?php 
					if(!isset($fieldOptions[$valueToShow]))
					{
						continue;
					}
				?>
				<?php  
					
				
				?>
					<li>
						<a href="<?php echo $appHtml->url("/",$appHtml->fullUrl,array("dynamicPage"=>array("field"=>$pageInfo['DynamicPage']['field'],'value'=>$valueToShow)))?>">
							<?php echo $fieldOptions[$valueToShow];?>
						</a>
					</li>
		<?php 
				unset($fieldOptions[$valueToShow]);
			}?>
		<?php if(count($fieldOptions)> 0){?>
		<li class="last">
			<?php 
				echo $html->link(__("More .. "),'javascript:void(0)',array("onclick"=>"$('#$hiddenDivId').toggle();$(this).hide(),$(this).next('a').show();"));
				echo $html->link(__(" less.."),'javascript:void(0)',array("onclick"=>"$('#$hiddenDivId').toggle();$(this).hide(),$(this).prev('a').show();",'style'=>"display:none"));
			?>
		</li>
		<?php }?>
	</ul>
    </div><!--dynamic_page_visible_links-->
</div><!--inder_text_more-->  
<div class="hidden_page_links" style="display:none" id="<?php echo $hiddenDivId?>">
                <ul>
                        <?php  foreach($fieldOptions as $value => $fieldOption){?>
                        <li>
                                        <a href="<?php echo $appHtml->url("/",$appHtml->fullUrl,array("dynamicPage"=>array("field"=>$pageInfo['DynamicPage']['field'],'value'=>$value)))?>">
                                                <?php echo $fieldOption;?>
                                        </a>
                        </li>
                        <?php }?>
                </ul>
</div>